package com.sahyadri.web.enums;


public enum SortOrder {
	
	ASC("ASCENDING", "ASC"),
	DESC("DESCENDING", "DESC"); 
	
	private String fullName;
	private String shortName;
	
	SortOrder(String fn, String sn) {
		this.fullName = fn;
		this.shortName = sn;
	}
	
	public static SortOrder fromString(String shortOrFullName) {
		
		if ("ASC".equalsIgnoreCase(shortOrFullName) || 
			"ASCENDING".equalsIgnoreCase(shortOrFullName)) {
		
			return ASC;
		}
		
		if ("DESC".equalsIgnoreCase(shortOrFullName) || 
			"DESCENDING".equalsIgnoreCase(shortOrFullName)) {
			
			return DESC;
		}
		
		throw new IllegalArgumentException("No SortOrder matches the specified sortString: " + shortOrFullName);
	}

	public String getFullName() {
		return fullName;
	}

	public String getShortName() {
		return shortName;
	}

}
